package cn.epsilon3.interceptor;

import cn.dev33.satoken.stp.StpInterface;
import cn.epsilon3.domain.e3.po.AccountInfo;
import cn.epsilon3.utils.SecurityUtils;
import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.List;

/**
 * <p>
 * sa-token 角色、权限绑定
 * </p>
 *
 * @author epsilon3
 * @since 2023-08-11
 */
@Service
public class SaTokenAuth implements StpInterface {

    @Override
    public List<String> getPermissionList(Object o, String s) {
        return SecurityUtils.principal().getPerms();
    }

    @Override
    public List<String> getRoleList(Object o, String s) {
        AccountInfo accountInfo = SecurityUtils.currentAccount();
        return Collections.singletonList(accountInfo.getRole().getRoleSign());
    }
}
